package org.jeecg.modules.app.v1.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.ApiLogin;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.app.util.NumberArithmeticUtils;
import org.jeecg.modules.aspect.ApiLoginAspct;
import org.jeecg.modules.power.group.entity.GroupUser;
import org.jeecg.modules.power.group.entity.SysUserExtends;
import org.jeecg.modules.power.group.entity.YlGroup;
import org.jeecg.modules.power.group.entity.YlGroupUser;
import org.jeecg.modules.power.group.service.IYlGroupService;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.vo.SysUserRoleVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
* @Description: 小组表
* @Author: jeecg-boot
* @Date:   2024-07-23
* @Version: V1.0
*/
@Api(tags="APP管理端_登录用户获取小组信息")
@RestController
@RequestMapping("/api/v1/group")
@Slf4j
@RequiredArgsConstructor
public class ApiGroupController{

   private final IYlGroupService ylGroupService;

   /**
    *
    * @param request
    * @return
    */
   @ApiLogin
   @ApiOperation(value="获取用户小组信息", notes="获取用户小组信息")
   @GetMapping(value = "/userGroup")
   public Result<GroupUser> userGroup(HttpServletRequest request) {
       SysUser bd = (SysUser)request.getAttribute(ApiLoginAspct.SYS_USER);
       GroupUser groupUser = ylGroupService.getUserGroup(bd.getId());
       if(oConvertUtils.isEmpty(groupUser))return Result.error_599("未查询到该用户信息，请重新登陆");
       return Result.OK(groupUser);
   }




}
